<%@page import="org.apache.struts2.components.Include"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>确认支付</title>
	<link rel="stylesheet" href="css/bootstrap.css"></link>
	<link rel="stylesheet" href="css/style.css"></link>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.easydropdown.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<style>
		.men fieldset{
			margin:2% 10% 3% 10%
		}
		.price_show div{
			display:inline-block
		}
	</style>
  </head>
  
  <body>
  <%@include file="common/head.jsp"%>
  <div class="menu">
	</div>
    <div class="men">
    	<fieldset>
    		<legend>订单信息</legend>
    		<table>
	    		<tr><td>下单时间:&nbsp;&nbsp;</td><td>${orders.creDate}</td><td>&nbsp;&nbsp;&nbsp;</td><td>单号:&nbsp;&nbsp;</td><td>${orders.num}</td></tr>
	    	</table>
    		<fieldset>
		    	<legend>商品详情</legend>
		    	<table>
					<s:iterator value="orders.ordergoodses" id="ordergoodses">
						<th>
							<legend>卖家: <s:property value="#ordergoodses.goods.user.name"/></legend>
						</th>
						<tr>
							<td>商品名</td>
							<td>${ordergoodses.name}</td>
						</tr>
						<tr>
							<td>描述</td>
							<td>${ordergoodses.remark}</td>
						</tr>
						<tr>
							<td>价格</td>
							<td>${ordergoodses.price}元</td>
						</tr>
						<tr>
							<td>数量</td>
							<td>${ordergoodses.amount}</td>
						</tr>
						<tr>
							<td>小计</td>
							<td class="subtotal">${ordergoodses.amount * ordergoodses.price}</td>
						</tr>
					</s:iterator>
				</table>
		    </fieldset>
		    <div class="price_show" style="float:right;width:400px;">
		    	<div>总金额:</div>
		    	<div><h1 id="total"></h1><input type="hidden" name="newOrder.money"/></div>
		    	<div>元</div>
		    </div>
		    <div class="price_show" style="float:right;width:300px;">
		    	<input type="button" class="btn_form form input" value="确认收货" onclick="confirmPay('${orders.num}')"/>
		    </div>
    	</fieldset>
	    
    </div>
	<script type="text/javascript">
		function confirmPay(orderNum) {
			if(confirm("请收到货后，再确认收货！否则您可能钱货两空！")){
				$.ajax({
					url : "changeStatus.action",
					type : "post",
					data : {
						"orderNum" : orderNum,
						"orderStatus" : "004",
					},
					dataTpye : "json",
					success : function(data) {
						data = JSON.parse(data).data;
						if(data == "success") {
							alert('您已经确认收货！即将返回"我是买家-我的订单管理"！');
							setTimeout(window.location.href = "userOrders.action",3000);
						} else if(data == "errorUser") {
							alert("请勿篡改他人数据！");
						} else if(data == "error") {
							alert("数据处理异常！");
						}
					}
				});
			} else {
				return false;
			}
		}

		$(document).ready(function() {
			var total = 0;
			$(".subtotal").each(function() {
				total += parseFloat($(this).text());
			});
			$("#total").text(total.toFixed(2));
		});
	</script>
	<%@include file="common/footer.jsp"%>
  </body>
</html>
